package notifiers;

import java.util.List;

import models.Organizacion;
import models.User;

import org.apache.commons.mail.HtmlEmail;

import play.Logger;
import play.data.validation.URL;
import play.mvc.Mailer;

public class Mails extends Mailer {

	/**
	 * Sends the welcome email to a recently registered user.
	 * 
	 * @param user
	 */
	public static void welcomeEmail(User user, List<Organizacion> organizaciones, String subject, String mensaje) throws Exception {
		Logger.info("Starting welcomeEmail email proccess...", new Object[] {});
		Logger.debug("user %s", user);
		setSubject(subject);
//		for (Organizacion organizacion : organizaciones) {
//			if (organizacion.mail != null) {
//				String[] emails = organizacion.mail.split(",");
//				for (String email : emails) {
//					addRecipient(email);
//				}
//			}
//		}
		// set the alternative message
		addRecipient("agustinabm@hotmail.com");
		//addRecipient("medusa@arcadiaconsultora.com");
		setFrom("ARCADIA <support@re-organizate.com>");
		if (!sendAndWait(user, mensaje))
			throw new Exception();
		Logger.info("Finishing welcomeEmail  email proccess...", new Object[] {});
	}

}
